package com.fin.zw.intelligentbot.entity;


import com.fin.zw.intelligentbot.enums.Status;
import com.fin.zw.intelligentbot.enums.Whether;
import lombok.Data;
import org.hibernate.annotations.Table;

import javax.persistence.*;
import java.util.Set;

@Entity
@Table(appliesTo = "role_info",comment="角色信息表")
@Data
public class RoleInfo extends BaseEntity{

    @Column(columnDefinition = "varchar(100) COMMENT '角色名称'")
    private String name;

    @Column(columnDefinition = "varchar(20) COMMENT '状态'")
    @Enumerated(EnumType.STRING)
    private Status status;

    @Column(columnDefinition = "varchar(20) COMMENT '是否是管理员'")
    @Enumerated(EnumType.STRING)
    private Whether whether = Whether.NO;

    @Column(columnDefinition = "varchar(100) COMMENT '备注'")
    private String remark;

    @ManyToMany(fetch = FetchType.EAGER)
    @JoinTable(name = "role_resource", joinColumns = @JoinColumn(name = "role_id"), inverseJoinColumns = @JoinColumn(name = "resource_id"))
    private Set<Resource> resources;
}
